﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ZYPPC6
{
    public partial class Form六爻起卦 : Form
    {
        private ZYOPPC.class六爻起卦 gua;
        public ZYOPPC.class六爻起卦 卦
        {
            set { gua = value; }
        }

        public Form六爻起卦()
        {
            InitializeComponent();
        }

        private void Form六爻起卦_Load(object sender, EventArgs e)
        {
            ZYOPPC.ZYDateTime zydt = new ZYOPPC.ZYDateTime(DateTime.Now);
            labelZYDate.Text = zydt.Name;

            // show 段卦爻表
            foreach (String key in gua.段卦爻表.Keys)
            {
                String[] k = new String[2];
                k[0] = key;
                k[1] = gua.段卦爻表[key].ToString();

                ListViewItem lvi = new ListViewItem(k);
                listViewKey.Items.Add(lvi);
            }


            // Show 本卦
            String[] g = new String[4];

            for (int i = 5; i >= 0; i--)
            {
                g[0] = gua.本卦.爻s[i].爻ctrl;
                if (gua.用神不现)
                {
                    g[1] = gua.本卦.卦宫64.爻s[i].Name;
                }
                else
                {
                    g[1] = string.Empty;
                }


                if (gua.本卦.世爻.ID == i)
                {
                    g[2] = "世 ";
                }
                else
                {
                    if (gua.本卦.应爻.ID == i)
                    {
                        g[2] = "应 ";
                    }
                    else
                    {
                        g[2] = String.Empty;
                    }
                }

                g[2] += gua.本卦.爻s[i].Name;
                if (null != gua.本卦.变卦)
                {
                    g[3] = gua.本卦.变卦.爻s[i].Name;
                }
                else
                {
                    g[3] = String.Empty;
                }

                ListViewItem lvi = new ListViewItem(g);
                listView1.Items.Add(lvi);
            }
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            this.gua.Save(this.textBoxComments.Text,String.Empty);
        }
    }
}